<script>
import EzListViewer from "@/comps/list/EzListViewer.vue";
import EzViewer from "@/comps/viewer/EzViewer.vue";
import TitleA from "@/comps/comm/TitleA.vue";
import EzViewerBuilder from "@/comps/viewer/EzViewerBuilder";
import listBuilder from "@/comps/list/listBuilder";
import apiInquiry from "@/pages/v1/erp/Inquiry/js/apiInquiry";
import apiInquiryProduct from "@/pages/v1/erp/InquiryProduct/js/apiInquiryProduct";
import apiInquiryFeedback from "@/pages/v1/erp/InquiryFeedback/js/apiInquiryFeedback";
import apiInquiryFeedbackProduct from "@/pages/v1/erp/InquiryFeedbackProduct/js/apiInquiryFeedbackProduct";

export default {
  name: "ViewerInquiryFeedback",
  components: {TitleA, EzViewer, EzListViewer},
  props: {
    model: {},
  },
  data() {
    let vb = EzViewerBuilder()
    vb.add("sn","单据编号",3).setViewIsText().setViewCopy()
    vb.add("title","单据主题",6).setViewIsText()
    vb.add("status","状态",3).setViewIsStatus()


    vb.add("sellerName","供应商",2).setViewIsText()
    vb.add("payType","付款方式",2).setViewIsObjectName()
    vb.add("deliver","交货地点",2).setViewIsText()
    vb.add("contactEmp","业务员",2).setViewIsObjectName()
    vb.add("contact","联系人",2).setViewIsText()
    vb.add("contactPhone","联系电话",2).setViewIsText()


    vb.add("formEmp","制单人",2).setViewIsObjectName()
    vb.add("formAt","制单时间",2).setViewIsDate()
    vb.add("createEmp","创建人",2).setViewIsObjectName()
    vb.add("isConfirm","是否生效",2).setViewIsBool()
    vb.add("isCancel","是否取消",2).setViewIsBool()
    vb.add("isClose","是否关闭",2).setViewIsBool()
    vb.add("createAt","创建时间",2).setViewIsDateTime()
    vb.add("updateAt","更新时间",2).setViewIsDateTime()
    vb.add("confirmAt","生效时间",2).setViewIsDate()
    vb.add("note","备注",12).setViewIsText().setViewSpanSm(12)

    let lb = listBuilder()
    lb.add("id","#",80)
    // lb.add("belongTo","询价单",180).setListIsObject("title")
    lb.add("product","产品",180).setListIsObjectName()
    lb.add("num","数量",80)
    lb.add("unit","单位",80).setListIsObjectName()
    lb.add("taxRate","税率",180).setListIsObjectName()
    lb.add("price","参考单价",180)
    lb.add("money","参考总价",180)
    lb.add("note","备注",0)
    lb.add("row","RN",80)
    lb.add("belongToId","询价单",70)
    return {
      items:vb.items,
      curTab:"main",
      //列表数据
      confList:lb.headers,
      data:[],
      inSideModel:null,
    }
  },
  mounted() {
    this.getData()
    this.getProduct()
  },
  methods:{
    getData(){
      apiInquiryFeedback.findBy({
        _where:{id:this.model.id},
        _dumps:["payType","contactEmp","status","formEmp","createEmp"],
        page:1, limit:1,
      },res=>{
        this.inSideModel=res[0]
      })
    },
    getProduct(){
      apiInquiryFeedbackProduct.findBy({
        _where:{belongToId:this.model.id},
        _dumps:["belongTo","product","unit","taxRate"],
        page:1, limit:0,
      },res=>{this.data = res})
    }
  }
}
</script>


<template>
  <div class="pad5">
    <title-a class="mart10 fs8">基础信息</title-a>
    <mu-row class="bdtso bdlso" fill :gutter="true" align-items="stretch">
      <mu-col fill class="pad3 bcf bdrso bdbso" :span="item.span" v-for="item in items" :key="item.key">
        <div class="fwb fs9 tar padr3" style="width: 80px;">{{item.label}}:</div>
        <div class="flex1"><EzViewer :config="item" :model="inSideModel"></EzViewer></div>
      </mu-col>
    </mu-row>
    <title-a class="mart10 fs8">明细列表</title-a>
    <mu-data-table stripe :columns="confList" height="440" :data="data" rowKey="id" >
      <template slot-scope="scope">
        <td :align="col.align" v-for="col in confList" :key="`${scope.row.id}${col.name}`">
          <!--这个ID只是一个自定义的示例-->
          <div :class="`ez-${col.align}`" v-if="col.name === 'id'">{{ scope.row.id }}</div>
          <EzListViewer :class="`ez-${col.align}`" v-else :config="col" :row="scope.row"></EzListViewer>
        </td>
      </template>
    </mu-data-table>
  </div>
</template>

<style scoped>

</style>